package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.ArrayList;

import static java.lang.String.format;

public class StartUp {

    private PrintStream printStream;

    public StartUp(PrintStream printStream) {
        this.printStream = printStream;
    }

    public void welcome() {
        this.printStream.println("Welcome");
    }

    public void menuOptions() {
        printStream.println("Menu");
        printStream.println("1. Books");
        printStream.println("2. Checkout");
        printStream.println("3. Check Membership Details");
        printStream.println("4. See Movie Details");
        printStream.println("Select an option");
    }

    public void printErrorMessage() {
        printStream.println("Select a Valid Option!!");
    }

    public void bookDoesNotExist() {
        printStream.println("Sorry we don't have that book yet.");
    }

    public void thankyouForReservingBook() {
        printStream.println("Thank You! Enjoy the book.");
    }

    public void handleOption(OptionInput optionInput1, ArrayList<Book> bookList, ArrayList<Movie> movieList) {
        switch (optionInput1) {
            case OPTION_INPUT1:
                for (int i = 0; i < bookList.size(); i++) {
                    printStream.println((i + 1) + ". " + bookList.get(i).getTitle());
                }
                break;
            case OPTION_INPUT2:
                printStream.println("Please enter books you want to checkout");
                break;
            case OPTION_INPUT3:
                printStream.println("Please talk to a Librarian. Thank you.");
                break;
            case OPTION_INPUT4:

                printStream.printf("%-20s %5s %-20s %2s\n", "Movie", "Year", "Director", "Rating");
                for (Movie movie : movieList) {
                    printStream.println(movie.toString());
                }
                break;
            default:
                printStream.println("Invalid option");
        }

    }
}
